package com.jiyun.service.impl;

/*import com.bst.common.dto.BstResponse;
import com.bst.common.entity.DemandInfo;
import com.bst.common.service.IDemandInfoService;
import com.pp.third.dto.MQMessageDto;
import com.pp.third.dto.RoleAuthority;*/

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jiyun.mapper.UserMapper;
import com.jiyun.service.IUacUserDetailService;
import com.jiyun.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;

@Slf4j
@Service("uacUserDetailService")
public class UacUserDetailServiceImpl implements UserDetailsService, IUacUserDetailService {

    @Resource
    private PasswordEncoder passwordEncoder;
    @Resource
    UserService userService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        LambdaQueryWrapper<com.jiyun.pojo.XUser> qw = new LambdaQueryWrapper<com.jiyun.pojo.XUser>();
         qw.eq(com.jiyun.pojo.XUser::getUsername, username);
        com.jiyun.pojo.XUser one = userService.getOne(qw);
        Collection<SimpleGrantedAuthority> authorities = new ArrayList();
        UserDetails userDetails = new User(one.getUsername(), passwordEncoder.encode(one.getPassword()),authorities);
        return userDetails;
    }

   /* @Override
    public Boolean enterPhoneNumber(String phone) throws InterruptedException {
        DemandInfo demandInfo = new DemandInfo();
        demandInfo.setDemandBindPhone(phone);
        return this.doEnterPhoneNumber(demandInfo);
    }

    @Override
    public Boolean doEnterPhoneNumber(DemandInfo demandInfo) {
        return demandInfoService.insertDemandInfo(demandInfo);
    }
*/
}
